<?php

namespace App\Console\Commands;

use App\Models\User;
use App\Models\UserMenu;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Hash;

class Install extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'install';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '初始化安装';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return int
     */
    public function handle()
    {
        $this->output->info('正在建立数据库初始化');
        $this->call('migrate');
        $this->output->info('初始化默认数据');
        // 创建默认菜单
        UserMenu::insert([
            [
                'title' => '用户中心',
                'url' => '/user/dashboard',
                'icon' => 'dashboard',
                'order' => 1
            ],
            [
                'title' => '我的商户',
                'url' => '/user/merchants',
                'icon' => 'merchants',
                'order' => 2
            ],
            [
                'title' => '我的订单',
                'url' => '/user/orders',
                'icon' => 'orders',
                'order' => 3,
            ],
            [
                'title' => '资金明细',
                'url' => '/user/balance-logs',
                'icon' => 'balance-logs',
                'order' => 4,
            ],
            [
                'title' => '提现记录',
                'url' => '/user/cash-draws',
                'icon' => 'cash-draws',
                'order' => 5,
            ],
            [
                'title' => '提现信息',
                'url' => '/user/cash-infos',
                'icon' => 'cash-infos',
                'order' => 6
            ]
        ]);

        return 0;
    }
}
